package com.cloud.wms.tools;

import android.app.DatePickerDialog;
import android.content.Context;
import android.widget.TextView;

import com.cloud.wms.R;
import com.google.android.material.datepicker.CalendarConstraints;
import com.google.android.material.datepicker.DateValidatorPointBackward;
import com.google.android.material.datepicker.DateValidatorPointForward;
import com.google.android.material.datepicker.MaterialDatePicker;

import java.util.Calendar;
import java.util.Date;

/**
 * @Author:Chen
 * @Date: 2021-01-25 11:15
 * @Description:
 */
public class DatePickerUtils {
    public static DatePickerDialog datePicker(Context context, boolean isTodayAfter, DatePickerDialog.OnDateSetListener listener) {
        Calendar calendar = Calendar.getInstance();
        DatePickerDialog mDateDialog = new DatePickerDialog(context,
                listener,
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH));
        if (isTodayAfter) {
            mDateDialog.getDatePicker().setMinDate(new Date().getTime());
        } else {
            mDateDialog.getDatePicker().setMaxDate(new Date().getTime());
        }
        return mDateDialog;
    }
}
